package com.leetcodehot.problems;

import java.util.ArrayList;
import java.util.List;

public class problems77 {
    private int n;
    private int k;
    private List<List<Integer>> res = new ArrayList<>();
    private List<Integer> path = new ArrayList<>();

    public List<List<Integer>> combine(int _n, int _k) {
        n = _n;
        k = _k;
        dfs(n);
        return res;
    }

    private void dfs(int i) {
        int d = k - path.size();
        if (d == 0) {
            res.add(new ArrayList<>(path));
            return;
        }
        for (int j = i; j >= d; j--) {
            path.add(j);
            dfs(j - 1);
            path.remove(path.size() - 1);
        }
    }
}
